package com.webbei.Backstage.action;

import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.webbei.Backstage.service.BackstateSer;
import com.webbei.friendcenter.service.MyFriendCenter;
import com.webbei.pojo.Cartypes;

public class DeleteCarTypesByCarTypesIdAction {
	private BackstateSer bao;
	private int cartypeid;
	private List<Cartypes> carTypes;
	private String PicName;
	public String execute(){
		int i=bao.deleteCarTypesBycartypeid(cartypeid);
		HttpServletResponse response=ServletActionContext.getResponse();
		if(i==1){
			//String path=ServletActionContext.getRequest().getContextPath();
			String path=ServletActionContext.getServletContext().getRealPath("/");
			File file=new File(path+"CarMark/"+PicName);
			file.delete();
			try {
				response.getWriter().write("success");
				response.setContentType("text/html");
			} catch (IOException e) {
				e.printStackTrace();
			}	
		}else{
			try {
				response.getWriter().write("fail");
				response.setContentType("text/html");
			} catch (IOException e) {
				e.printStackTrace();
			}	
		}
		return null;
	}
	
	public String getPicName() {
		return PicName;
	}

	public void setPicName(String picName) {
		PicName = picName;
	}

	public List<Cartypes> getCarTypes() {
		return carTypes;
	}
	public void setCarTypes(List<Cartypes> carTypes) {
		this.carTypes = carTypes;
	}
	public int getCartypeid() {
		return cartypeid;
	}
	public void setCartypeid(int cartypeid) {
		this.cartypeid = cartypeid;
	}
	public BackstateSer getBao() {
		return bao;
	}
	public void setBao(BackstateSer bao) {
		this.bao = bao;
	}
	
}
